package com.landlord.project;

import java.util.*;

public class LandlordView {

    //获取分发好的纸牌
    static List<LandlordData> list = Farmer.getLs().getList();
    //选地主
    static final int NUM = Farmer.randomLandlord();
    static Scanner input = new Scanner(System.in);
    //上家牌的value
    static List<Integer> valueList1 = new ArrayList<>(20);
    //本家牌的value
    static List<Integer> valueList2 = new ArrayList<>(20);

    //记录出牌的回合数
    static int i = 0;
    //三个玩家
    static Farmer l1 = Farmer.getFarmer()[NUM];
    static Farmer l2 = Farmer.getFarmer()[(NUM + 1) % 3];
    static Farmer l3 = Farmer.getFarmer()[(NUM + 2) % 3];

    public static void doMain(){

        //自然排序(方法一)
        Collections.sort(list);
        //自定义排序(方法二)
//        Collections.sort(list, new Comparator<LandlordsData>() {
//            @Override
//            public int compare(LandlordsData o1, LandlordsData o2) {
//                return o1.getValue()<o2.getValue()?-1:o1.getValue()==o2.getValue()?0:1;
//            }
//        });
        System.out.println(NUM+1+"号玩家被选为地主");
        //遍历查找三张地主牌给地主
        Farmer f1 = Farmer.getFarmer()[0];
        Farmer f2 = Farmer.getFarmer()[1];
        Farmer f3 = Farmer.getFarmer()[2];
        System.out.print("地主牌:");
        for (LandlordData ld : list){
            switch (ld.getMode()){
                case 0:
                    f1.getList().add(ld);
                    break;
                case 1:
                    f2.getList().add(ld);
                    break;
                case 2:
                    f3.getList().add(ld);
                    break;
                default:
                    Farmer.getFarmer()[NUM].getList().add(ld);
                    System.out.print("\t"+ld);
            }
        }
        System.out.println("\n*************************");


        System.out.println("玩家一");
        System.out.println(f1);
        for (LandlordData ld : f1.getList()){
            System.out.println(ld.getToString());
        }
        System.out.println("\n*************************");

        System.out.println("玩家二");
        System.out.println(f2);
        for (LandlordData ld : f2.getList()){
            System.out.println(ld.getToString());
        }
        System.out.println("\n*************************");

        System.out.println("玩家三");
        System.out.println(f3);
        for (LandlordData ld : f3.getList()){
            System.out.println(ld.getToString());
        }
        System.out.println("\n*************************");





        while (true) {
            fuck(l1,l2,l3,"地主");
            if (l1.getList().isEmpty()) {
                System.out.println("地主获胜");
                break;
            }


            fuck(l2,l1,l3,"农民甲");
            if (l2.getList().isEmpty()){
                System.out.println("农民获胜");
                break;
            }


            fuck(l3,l2,l1,"农民乙");
            if (l3.getList().isEmpty()){
                System.out.println("农民获胜");
                break;
            }
        }
        input.close();
    }

    public static void fuck(Farmer f1,Farmer f2,Farmer f3,String str) {
        while (true) {

            System.out.println(str);
            System.out.println(f1.getList());


            if (f2.isCardprint() || f3.isCardprint()) {
                System.out.println("(value)出牌     (\\r)不出");
            }
            String sum = "";
            valueList2.clear();
            sum = input.nextLine();
            if (f2.isCardprint() || f3.isCardprint()) {
                if ("".equals(sum)) {
                    f1.setCardprint(false);
                    i++;
                    break;
                }
            }
            for (int i=0;i<sum.length();i++){
                if (sum.charAt(i)=='1'){
                    valueList2.add(getVal(sum.charAt(i)));
                    i++;
                }else {
                    valueList2.add(getVal(sum.charAt(i)));
                }
            }


            List<LandlordData> candis = getLd(f1, valueList2);
            if (candis==null){
                System.out.println("牌型不存在,重新输入");
                continue;
            }

            //上两家没人出 本家必须出牌
            if (valueList2.isEmpty()) {
                System.out.println("牌型不合法,重新输入");
                continue;
            }

            String s1 = cardDecide(valueList1);
            String s2 = cardDecide(valueList2);
            if (!("X".equals(s2))) {
                isPrt(s2);
                if (f2.isCardprint() || f3.isCardprint()) {
                    if (!cardPrime(s1, s2)) {
                        System.out.println("与上家牌型不符,重新输入");
                        continue;
                    }
                }
                i++;
                f1.getList().removeAll(candis);
                f1.setCardprint(true);
                valueList1.clear();
                valueList1.addAll(valueList2);
                break;
            }
            System.out.println("牌型不合法,重新输入");
        }
    }







    //输入代号判断是否符合牌型list2>list1
    private static boolean cardPrime(String str1,String str2){
        if (str1.length()==1){
            return false;
        }
        if (str2.length()==1){
            return true;
        }
        if (str1.charAt(0)=='A'){
            if (str2.charAt(0)=='A'){
                String s1 = str1.substring(2);
                String s2 = str2.substring(2);
                if (s1.length()<s2.length()){
                    return true;
                }else if (s1.length()>s2.length()){
                    return false;
                }
                int len1 = Integer.parseInt(s1);
                int len2 = Integer.parseInt(s2);
                return len1<len2;
            }
            return false;
        }
        if (str2.charAt(0)=='A'){
            return true;
        }
        //切成前后两块
//        String[] s1 = str1.split("Y");
//        String[] s2 = str2.split("Y");
//        if (s1[0].length()!=s2[0].length()){
//            return false;
//        }
//        if (!(s1[0].equals(s2[0]))){
//            return false;
//        }
//        if (Integer.parseInt(s1[1])>=Integer.parseInt(s2[1])){
//            return false;
//        }
//        return true;
        //通过索引比较
        int len1 = str1.indexOf('Y');
        int len2 = str2.indexOf('Y');
        if (len1!=len2){
            return false;
        }
        if (!(str1.regionMatches(0,str2,0,len1))){
            return false;
        }
        String str3 = str1.substring(len1+1);
        String str4 = str2.substring(len2+1);
        if (str3.length()<str4.length()){
            return true;
        }
        if (str3.length()>str4.length()){
            return false;
        }
        if (Integer.parseInt(str3)>=Integer.parseInt(str4)){
            return false;
        }
        return true;
    }
    //输入value判断索引返回出牌的列表
    public static List<LandlordData> getLd(Farmer l,List<Integer> valueList){
        List<LandlordData> list = new ArrayList<>(20);
        List<Integer> listInt = new ArrayList<>(20);
        listInt.addAll(valueList);
        int flog = 0;
        for (LandlordData ld : l.getList()){
            for (int i : listInt) {
                if (i == ld.getValue()) {
                    //优先删除指定索引 手动装箱删除指定对象
                    listInt.remove(new Integer(i));
                    list.add(ld);
                    break;
                }
            }
        }
        if (!listInt.isEmpty()){
            return  null;
        }
        return list;
    }
    //输入面值判断value
    public static int getVal(char c){
        switch (c) {
            //真值为10
            case '1':
                return 7;
            case 'J':
                return 8;
            case 'Q':
                return 9;
            case 'K':
                return 10;
            case 'A':
                return 11;
            case '2':
                return 12;
            case '-':
                return 13;
            case '+':
                return 14;
            default:
                return c-48-3;
        }
    }
    //输入value判断面值
    public static String getStr(int num){
        switch (num) {
            case 7:
                return "10";
            case 8:
                return "J";
            case 9:
                return "Q";
            case 10:
                return "K";
            case 11:
                return "A";
            case 12:
                return "2";
            case 13:
                return "小王";
            case 14:
                return "大王";
            default:
                return num + 3 + "";
        }
    }
    //输入代号打印牌型
    public static void isPrt(String str){

        if (str.charAt(0)=='A'){
            if (str.length()==1){
                System.out.println("王炸");
            }else {
                System.out.println("炸弹"+"value:"+getStr(Integer.parseInt(str.substring(2))));
            }
            return;
        }
        String[] s1 = str.split("Y");
        int xr = Integer.parseInt(s1[1]);
        if (s1[0].length()==1){
            switch (s1[0]){
                case "G":
                    System.out.println("三带一对"+"value:"+getStr(xr));
                    break;
                case "H":
                    System.out.println("三带一"+"value:"+getStr(xr));
                    break;
                case "I":
                    System.out.println("三个"+getStr(xr));
                    break;
                case "J":
                    System.out.println("对子"+getStr(xr));
                    break;
                case "K":
                    if (xr!=13&&xr!=14){
                        System.out.print("一张");
                    }
                    System.out.println(getStr(xr));
                    break;
                case "L":
                    System.out.println("四带二"+"value:"+getStr(xr));
                    break;
                case "M":
                    System.out.println("四带两对"+"value:"+getStr(xr));
                    break;
            }
        }else {
            switch (s1[0].charAt(0)){
                case 'B':
                    System.out.println(Integer.parseInt(s1[0].substring(2))+"连顺"+"value:"+getStr(xr));
                    break;
                case 'C':
                    System.out.println(Integer.parseInt(s1[0].substring(2))+"连对"+"value:"+getStr(xr));
                    break;
                case 'D':
                    System.out.println(Integer.parseInt(s1[0].substring(2))+"连飞机0"+"value:"+getStr(xr));
                    break;
                case 'E':
                    System.out.println(Integer.parseInt(s1[0].substring(2))+"连飞机1"+"value:"+getStr(xr));
                    break;
                case 'F':
                    System.out.println(Integer.parseInt(s1[0].substring(2))+"连飞机2"+"value:"+getStr(xr));
                    break;
            }
        }

    }
    //判断是否是单顺
    public static boolean isFloatStraight(List<Integer> list){
        for (int i=0;i<list.size()-1;i++){
            if (list.get(i)!=(list.get(i+1)-1)){
                return false;
            }
        }
        return true;
    }
    //判断是否是连对
    private static boolean isDoubleStraight(List<Integer> list){
        for (int i=0;i<list.size()-2;i=i+2){
            if (list.get(i)!=(list.get(i+2)-1)||list.get(i)!=list.get(i+1)){
                return false;
            }
        }
        return true;
    }
    //判断是否是飞机
    private static boolean isAircraft(List<Integer> list){
        for (int i=0;i<list.size()-3;i=i+3){
            if (list.get(i)!=(list.get(i+3)-1)||list.get(i)!=list.get(i+2)){
                return false;
            }
        }
        return true;
    }
    //输入value判断牌型是否合法(如牌型有冲突，按最小)(仅适用于Integer包装类static提前造好常用的[-128,127])
    private static String cardDecide(List<Integer> cardList){
        Collections.sort(cardList);
        switch (cardList.size()){
            case 1:
                return "KY"+cardList.get(0);
            case 2:
                int sum21 = cardList.get(0);
                int sum22 = cardList.get(1);
                if (sum21==sum22){
                    return "JY"+sum21;
                }
                if (sum21==13&&sum22==14){
                    return "A";
                }
                return "X";
            case 3:
                if (cardList.get(0)==cardList.get(2)){
                    return "IY"+cardList.get(0);
                }
                return "X";
            case 4:
                //炸弹
                if (cardList.get(0)==cardList.get(3)){
                    return "AY"+cardList.get(0);
                }
                //三带一
                if (cardList.get(0)==cardList.get(2)||cardList.get(1)==cardList.get(3)){
                    return "HY"+cardList.get(1);
                }
                return "X";
            case 5:
                //三带一对
                if ((cardList.get(0)==cardList.get(2)&&cardList.get(3)==cardList.get(4))||(cardList.get(0)==cardList.get(1)&&cardList.get(2)==cardList.get(4))){
                    return "GY"+cardList.get(2);
                }
                //顺子
                //顺子最大到11(A)
                if (cardList.get(4)>11){
                    return "X";
                }
                if (isFloatStraight(cardList)){
                    return "BX5Y"+cardList.get(0);
                }
                return "X";
            case 6:
                //四带二
                if (cardList.get(0)==cardList.get(3)||cardList.get(1)==cardList.get(4)||cardList.get(2)==cardList.get(5)){
                    return "LY"+cardList.get(2);
                }
                //最大到11(A)
                if (cardList.get(5)>11){
                    return "X";
                }
                //飞机不带翅膀
                if (isAircraft(cardList)){
                    return "DX2Y"+cardList.get(0);
                }
                //三连对
                if (isDoubleStraight(cardList)){
                    return "CX3Y"+cardList.get(0);
                }
                //顺子
                if (isFloatStraight(cardList)){
                    return "BX6Y"+cardList.get(0);
                }
                return "X";
            case 7:
                //顺子
                //顺子最大到11(A)
                if (cardList.get(6)>11){
                    return "X";
                }
                if (isFloatStraight(cardList)){
                    return "BX7Y"+cardList.get(0);
                }
                return "X";
            case 8:
                //四带两对(炸弹在前)两对不能相同
//                if (cardList.get(0)==cardList.get(3)&&cardList.get(4)==cardList.get(5)&&cardList.get(5)!=cardList.get(6)&&cardList.get(6)==cardList.get(7)){
//                    return "MY"+cardList.get(0);
//                }
                //四带两对(炸弹在前)两对能相同
                if (cardList.get(0)==cardList.get(3)&&cardList.get(4)==cardList.get(5)&&cardList.get(6)==cardList.get(7)){
                    return "MY"+cardList.get(0);
                }
                //四带两对(炸弹在中)
                if (cardList.get(0)==cardList.get(1)&&cardList.get(2)==cardList.get(5)&&cardList.get(6)==cardList.get(7)){
                    return "MY"+cardList.get(2);
                }
                //四带两对(炸弹在后)两对不能相同
//                if (cardList.get(0)==cardList.get(1)&&cardList.get(1)!=cardList.get(2)&&cardList.get(2)==cardList.get(3)&&cardList.get(4)==cardList.get(7)){
//                    return "MY"+cardList.get(4);
//                }
                //四带两对(炸弹在后)两对能相同
                if (cardList.get(0)==cardList.get(1)&&cardList.get(2)==cardList.get(3)&&cardList.get(4)==cardList.get(7)){
                    return "MY"+cardList.get(4);
                }
                //相邻的炸弹到底算不算飞机
                //飞机1(双炸弹)
                if (cardList.get(6)<=11&&cardList.get(1)==cardList.get(3)&&cardList.get(3)+1==cardList.get(4)&&cardList.get(4)==cardList.get(6)){
                    return "EX2Y"+cardList.get(1);
                }
                //飞机1(可含单个炸弹)单牌在两边
//                if (cardList.get(6)<=11&&((cardList.get(0)!=cardList.get(1)&&cardList.get(1)==cardList.get(3)&&cardList.get(3)+1==cardList.get(4)&&cardList.get(4)==cardList.get(6))||(cardList.get(1)==cardList.get(3)&&cardList.get(3)+1==cardList.get(4)&&cardList.get(4)==cardList.get(6)&&cardList.get(6)!=cardList.get(7)))){
//                    return "EX2Y"+cardList.get(1);
//                }
                //飞机2飞机在前
                if (cardList.get(5)<=11&&cardList.get(0)==cardList.get(2)&&cardList.get(2)+1==cardList.get(3)&&cardList.get(3)==cardList.get(5)){
                    return "EX2Y"+cardList.get(0);
                }
                //飞机3飞机在后
                if (cardList.get(7)<=11&&cardList.get(2)==cardList.get(4)&&cardList.get(4)+1==cardList.get(5)&&cardList.get(5)==cardList.get(7)){
                    return "EX2Y"+cardList.get(2);
                }
                //最大到11(A)
                if (cardList.get(7)>11){
                    return "X";
                }
                //四连对
                if (isDoubleStraight(cardList)){
                    return "CX4Y"+cardList.get(0);
                }
                //顺子
                if (isFloatStraight(cardList)){
                    return "BX8Y"+cardList.get(0);
                }
                return "X";
            case 9:
                //最大到11(A)
                if (cardList.get(8)>11){
                    return "X";
                }
                //三飞机不带翅膀
                if (isAircraft(cardList)){
                    return "DX3Y"+cardList.get(0);
                }
                //顺子
                if (isFloatStraight(cardList)){
                    return "BX9Y"+cardList.get(0);
                }
                return "X";
            case 10:
                //飞机带两对(飞机在前)(两对能相同)
                if (cardList.get(0)==cardList.get(2)&&cardList.get(2)+1==cardList.get(3)&&cardList.get(3)==cardList.get(5)&&cardList.get(6)==cardList.get(7)&&cardList.get(8)==cardList.get(9)){
                    return "FX2Y"+cardList.get(0);
                }
                //飞机带两对(飞机在前)(两对不能相同)
//                if (cardList.get(0)==cardList.get(2)&&cardList.get(2)+1==cardList.get(3)&&cardList.get(3)==cardList.get(5)&&cardList.get(6)==cardList.get(7)&&cardList.get(7)!=cardList.get(8)&&cardList.get(8)==cardList.get(9)){
//                    return "FX2Y"+cardList.get(0);
//                }
                //飞机带两对(飞机在中)
                if (cardList.get(0)==cardList.get(1)&&cardList.get(2)==cardList.get(4)&&cardList.get(4)+1==cardList.get(5)&&cardList.get(5)==cardList.get(7)&&cardList.get(8)==cardList.get(9)){
                    return "FX2Y"+cardList.get(2);
                }
                //飞机带两对(飞机在后)(两对能相同)
                if (cardList.get(9)<=11&&cardList.get(0)==cardList.get(1)&&cardList.get(2)==cardList.get(3)&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)){
                    return "FX2Y"+cardList.get(4);
                }
                //飞机带两对(飞机在后)(两对不能相同)
//                if (cardList.get(9)<=11&&cardList.get(0)==cardList.get(1)&&cardList.get(1)!=cardList.get(2)&&cardList.get(2)==cardList.get(3)&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)){
//                    return "FX2Y"+cardList.get(4);
//                }
                //最大到11(A)
                if (cardList.get(9)>11){
                    return "X";
                }
                //五连对
                if (isDoubleStraight(cardList)){
                    return "CX5Y"+cardList.get(0);
                }
                //顺子
                if (isFloatStraight(cardList)){
                    return "BX10Y"+cardList.get(0);
                }
                return "X";
            case 11:
                //顺子
                //顺子最大到11(A)
                if (cardList.get(10)>11){
                    return "X";
                }
                if (isFloatStraight(cardList)){
                    return "BX11Y"+cardList.get(0);
                }
                return "X";
            case 12:
                //四飞机不带翅膀
                if (isAircraft(cardList)){
                    return "DX4Y"+cardList.get(0);
                }
                //三飞机带三单
                //飞机在前
                if (cardList.get(8)<=11&&cardList.get(0)==cardList.get(2)&&cardList.get(2)+1==cardList.get(3)&&cardList.get(3)==cardList.get(5)&&cardList.get(5)+1==cardList.get(6)&&cardList.get(6)==cardList.get(8)){
                    return "EX3Y"+cardList.get(0);
                }
                //飞机在中1
                if (cardList.get(9)<=11&&cardList.get(1)==cardList.get(3)&&cardList.get(3)+1==cardList.get(4)&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)){
                    return "EX3Y"+cardList.get(1);
                }
                //飞机在中2
                if (cardList.get(10)<=11&&cardList.get(2)==cardList.get(4)&&cardList.get(4)+1==cardList.get(5)&&cardList.get(5)==cardList.get(7)&&cardList.get(7)+1==cardList.get(8)&&cardList.get(8)==cardList.get(10)){
                    return "EX3Y"+cardList.get(2);
                }
                //飞机在后
                if (cardList.get(11)<=11&&cardList.get(3)==cardList.get(5)&&cardList.get(5)+1==cardList.get(6)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)){
                    return "EX3Y"+cardList.get(3);
                }
                //最大到11(A)
                if (cardList.get(11)>11){
                    return "X";
                }
                //六连对
                if (isDoubleStraight(cardList)){
                    return "CX6Y"+cardList.get(0);
                }
                //顺子
                if (isFloatStraight(cardList)){
                    return "BX12Y"+cardList.get(0);
                }
                return "X";
            case 14:
                //最大到11(A)
                if (cardList.get(13)>11){
                    return "X";
                }
                //七连对
                if (isDoubleStraight(cardList)){
                    return "CX7Y"+cardList.get(0);
                }
                return "X";
            case 15:
                //五飞机不带翅膀
                if (isAircraft(cardList)){
                    return "DX5Y"+cardList.get(0);
                }
                //飞机带三对 三对不能相同
//                //飞机在前
//                if (cardList.get(0)==cardList.get(2)&&cardList.get(2)+1==cardList.get(3)&&cardList.get(3)==cardList.get(5)&&cardList.get(5)+1==cardList.get(6)&&cardList.get(6)==cardList.get(8)&&cardList.get(9)==cardList.get(10)&&cardList.get(10)!=cardList.get(11)&&cardList.get(11)==cardList.get(12)&&cardList.get(12)!=cardList.get(13)&&cardList.get(13)==cardList.get(14)){
//                    return "FX3Y"+cardList.get(0);
//                }
//                //飞机在中1
//                if (cardList.get(0)==cardList.get(1)&&cardList.get(2)==cardList.get(4)&&cardList.get(4)+1==cardList.get(5)&&cardList.get(5)==cardList.get(7)&&cardList.get(7)+1==cardList.get(8)&&cardList.get(8)==cardList.get(10)&&cardList.get(11)==cardList.get(12)&&cardList.get(12)!=cardList.get(13)&&cardList.get(13)==cardList.get(14)){
//                    return "FX3Y"+cardList.get(2);
//                }
//                //飞机在中2
//                if (cardList.get(0)==cardList.get(1)&&cardList.get(1)!=cardList.get(2)&&cardList.get(2)==cardList.get(3)&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)&&cardList.get(9)+1==cardList.get(10)&&cardList.get(10)==cardList.get(12)&&cardList.get(13)==cardList.get(14)){
//                    return "FX3Y"+cardList.get(4);
//                }
//                //飞机在后
//                if (cardList.get(14)<=11&&cardList.get(0)==cardList.get(1)&&cardList.get(1)!=cardList.get(2)&&cardList.get(2)==cardList.get(3)&&cardList.get(3)!=cardList.get(4)&&cardList.get(4)==cardList.get(5)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)&&cardList.get(11)+1==cardList.get(12)&&cardList.get(12)==cardList.get(14)){
//                    return "FX3Y"+cardList.get(6);
//                }
                //飞机带三对 三对能任意相同
                //飞机在前
                if (cardList.get(0)==cardList.get(2)&&cardList.get(2)+1==cardList.get(3)&&cardList.get(3)==cardList.get(5)&&cardList.get(5)+1==cardList.get(6)&&cardList.get(6)==cardList.get(8)&&cardList.get(9)==cardList.get(10)&&cardList.get(11)==cardList.get(12)&&cardList.get(13)==cardList.get(14)){
                    return "FX3Y"+cardList.get(0);
                }
                //飞机在中1
                if (cardList.get(0)==cardList.get(1)&&cardList.get(2)==cardList.get(4)&&cardList.get(4)+1==cardList.get(5)&&cardList.get(5)==cardList.get(7)&&cardList.get(7)+1==cardList.get(8)&&cardList.get(8)==cardList.get(10)&&cardList.get(11)==cardList.get(12)&&cardList.get(13)==cardList.get(14)){
                    return "FX3Y"+cardList.get(0);
                }
                //飞机在中2
                if (cardList.get(0)==cardList.get(1)&&cardList.get(2)==cardList.get(3)&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)&&cardList.get(9)+1==cardList.get(10)&&cardList.get(10)==cardList.get(12)&&cardList.get(13)==cardList.get(14)){
                    return "FX3Y"+cardList.get(4);
                }
                //飞机在后
                if (cardList.get(14)<=11&&cardList.get(0)==cardList.get(1)&&cardList.get(2)==cardList.get(3)&&cardList.get(4)==cardList.get(5)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)&&cardList.get(11)+1==cardList.get(12)&&cardList.get(12)==cardList.get(14)){
                    return "FX3Y"+cardList.get(6);
                }
                return "X";
            case 16:
                //飞机(四飞机带四单)四单不能全相同
//                //飞机在前
//                if (cardList.get(0)==cardList.get(2)&&cardList.get(2)+1==cardList.get(3)&&cardList.get(3)==cardList.get(5)&&cardList.get(5)+1==cardList.get(6)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)&&cardList.get(12)!=cardList.get(15)){
//                    return "EX4Y"+cardList.get(0);
//                }
//                //飞机在中1
//                if (cardList.get(12)<=11&&cardList.get(1)==cardList.get(3)&&cardList.get(3)+1==cardList.get(4)&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)&&cardList.get(9)+1==cardList.get(10)&&cardList.get(10)==cardList.get(12)){
//                    return "EX4Y"+cardList.get(1);
//                }
//                //飞机在中2
//                if (cardList.get(13)<=11&&cardList.get(2)==cardList.get(4)&&cardList.get(4)+1==cardList.get(5)&&cardList.get(5)==cardList.get(7)&&cardList.get(7)+1==cardList.get(8)&&cardList.get(8)==cardList.get(10)&&cardList.get(10)+1==cardList.get(11)&&cardList.get(11)==cardList.get(13)){
//                    return "EX4Y"+cardList.get(2);
//                }
//                //飞机在中3
//                if (cardList.get(14)<=11&&cardList.get(3)==cardList.get(5)&&cardList.get(5)+1==cardList.get(6)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)&&cardList.get(11)+1==cardList.get(12)&&cardList.get(12)==cardList.get(14)){
//                    return "EX4Y"+cardList.get(3);
//                }
//                //飞机在后
//                if (cardList.get(15)<=11&&cardList.get(0)!=cardList.get(3)&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)&&cardList.get(9)+1==cardList.get(10)&&cardList.get(10)==cardList.get(12)&&cardList.get(12)+1==cardList.get(13)&&cardList.get(13)==cardList.get(15)){
//                    return "EX4Y"+cardList.get(4);
//                }
                //飞机(四飞机带四单)四单可以全相同
                //飞机在前
                if (cardList.get(0)==cardList.get(2)&&cardList.get(2)+1==cardList.get(3)&&cardList.get(3)==cardList.get(5)&&cardList.get(5)+1==cardList.get(6)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)){
                    return "EX4Y"+cardList.get(0);
                }
                //飞机在中1
                if (cardList.get(12)<=11&&cardList.get(1)==cardList.get(3)&&cardList.get(3)+1==cardList.get(4)&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)&&cardList.get(9)+1==cardList.get(10)&&cardList.get(10)==cardList.get(12)){
                    return "EX4Y"+cardList.get(1);
                }
                //飞机在中2
                if (cardList.get(13)<=11&&cardList.get(2)==cardList.get(4)&&cardList.get(4)+1==cardList.get(5)&&cardList.get(5)==cardList.get(7)&&cardList.get(7)+1==cardList.get(8)&&cardList.get(8)==cardList.get(10)&&cardList.get(10)+1==cardList.get(11)&&cardList.get(11)==cardList.get(13)){
                    return "EX4Y"+cardList.get(2);
                }
                //飞机在中3
                if (cardList.get(14)<=11&&cardList.get(3)==cardList.get(5)&&cardList.get(5)+1==cardList.get(6)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)&&cardList.get(11)+1==cardList.get(12)&&cardList.get(12)==cardList.get(14)){
                    return "EX4Y"+cardList.get(3);
                }
                //飞机在后
                if (cardList.get(15)<=11&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)&&cardList.get(9)+1==cardList.get(10)&&cardList.get(10)==cardList.get(12)&&cardList.get(12)+1==cardList.get(13)&&cardList.get(13)==cardList.get(15)){
                    return "EX4Y"+cardList.get(4);
                }
                //最大到11(A)
                if (cardList.get(15)>11){
                    return "X";
                }
                //八连对
                if (isDoubleStraight(cardList)){
                    return "CX8Y"+cardList.get(0);
                }
                return "X";
            case 18:
                //最大到11(A)
                if (cardList.get(17)>11){
                    return "X";

                }
                //六飞机不带翅膀
                if (isAircraft(cardList)){
                    return "DX6Y"+cardList.get(0);
                }
                //九连对
                if (isDoubleStraight(cardList)){
                    return "CX9Y"+cardList.get(0);
                }
                return "X";
            case 20:
                //四飞机四对(对对不能相同)
                //飞机在前
//                if (cardList.get(0)==cardList.get(2)&&cardList.get(2)+1==cardList.get(3)&&cardList.get(3)==cardList.get(5)&&cardList.get(5)+1==cardList.get(6)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)&&cardList.get(12)==cardList.get(13)&&cardList.get(13)!=cardList.get(14)&&cardList.get(14)==cardList.get(15)&&cardList.get(15)!=cardList.get(16)&&cardList.get(16)==cardList.get(17)&&cardList.get(17)!=cardList.get(18)&&cardList.get(18)==cardList.get(19)){
//                    return "FX4Y"+cardList.get(0);
//                }
//                //飞机在中1
//                if (cardList.get(0)==cardList.get(1)&&cardList.get(2)==cardList.get(4)&&cardList.get(4)+1==cardList.get(5)&&cardList.get(5)==cardList.get(7)&&cardList.get(7)+1==cardList.get(8)&&cardList.get(8)==cardList.get(10)&&cardList.get(10)+1==cardList.get(11)&&cardList.get(11)==cardList.get(13)&&cardList.get(14)==cardList.get(15)&&cardList.get(15)!=cardList.get(16)&&cardList.get(16)==cardList.get(17)&&cardList.get(17)!=cardList.get(18)&&cardList.get(18)==cardList.get(19)){
//                    return "FX4Y"+cardList.get(2);
//                }
//                //飞机在中2
//                if (cardList.get(0)==cardList.get(1)&&cardList.get(1)!=cardList.get(2)&&cardList.get(2)==cardList.get(3)&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)&&cardList.get(9)+1==cardList.get(10)&&cardList.get(10)==cardList.get(12)&&cardList.get(12)+1==cardList.get(13)&&cardList.get(13)==cardList.get(15)&&cardList.get(16)==cardList.get(17)&&cardList.get(17)!=cardList.get(18)&&cardList.get(18)==cardList.get(19)){
//                    return "FX4Y"+cardList.get(4);
//                }
//                //飞机在中3
//                if (cardList.get(0)==cardList.get(1)&&cardList.get(1)!=cardList.get(2)&&cardList.get(2)==cardList.get(3)&&cardList.get(3)!=cardList.get(4)&&cardList.get(4)==cardList.get(5)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)&&cardList.get(11)+1==cardList.get(12)&&cardList.get(12)==cardList.get(14)&&cardList.get(14)+1==cardList.get(15)&&cardList.get(15)==cardList.get(17)&&cardList.get(18)==cardList.get(19)){
//                    return "FX4Y"+cardList.get(6);
//                }
//                //飞机在后
//                if (cardList.get(19)<=11&&cardList.get(0)==cardList.get(1)&&cardList.get(1)!=cardList.get(2)&&cardList.get(2)==cardList.get(3)&&cardList.get(3)!=cardList.get(4)&&cardList.get(4)==cardList.get(5)&&cardList.get(5)!=cardList.get(6)&&cardList.get(6)==cardList.get(7)&&cardList.get(8)==cardList.get(10)&&cardList.get(10)+1==cardList.get(11)&&cardList.get(11)==cardList.get(13)&&cardList.get(13)+1==cardList.get(14)&&cardList.get(14)==cardList.get(16)&&cardList.get(16)+1==cardList.get(17)&&cardList.get(17)==cardList.get(19)){
//                    return "FX4Y"+cardList.get(8);
//                }
                //四飞机四对(对对可以相同)
                //飞机在前
                if (cardList.get(0)==cardList.get(2)&&cardList.get(2)+1==cardList.get(3)&&cardList.get(3)==cardList.get(5)&&cardList.get(5)+1==cardList.get(6)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)&&cardList.get(12)==cardList.get(13)&&cardList.get(14)==cardList.get(15)&&cardList.get(16)==cardList.get(17)&&cardList.get(18)==cardList.get(19)){
                    return "FX4Y"+cardList.get(0);
                }
                //飞机在中1
                if (cardList.get(0)==cardList.get(1)&&cardList.get(2)==cardList.get(4)&&cardList.get(4)+1==cardList.get(5)&&cardList.get(5)==cardList.get(7)&&cardList.get(7)+1==cardList.get(8)&&cardList.get(8)==cardList.get(10)&&cardList.get(10)+1==cardList.get(11)&&cardList.get(11)==cardList.get(13)&&cardList.get(14)==cardList.get(15)&&cardList.get(16)==cardList.get(17)&&cardList.get(18)==cardList.get(19)){
                    return "FX4Y"+cardList.get(2);
                }
                //飞机在中2
                if (cardList.get(0)==cardList.get(1)&&cardList.get(2)==cardList.get(3)&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)&&cardList.get(9)+1==cardList.get(10)&&cardList.get(10)==cardList.get(12)&&cardList.get(12)+1==cardList.get(13)&&cardList.get(13)==cardList.get(15)&&cardList.get(16)==cardList.get(17)&&cardList.get(18)==cardList.get(19)){
                    return "FX4Y"+cardList.get(4);
                }
                //飞机在中3
                if (cardList.get(0)==cardList.get(1)&&cardList.get(2)==cardList.get(3)&&cardList.get(4)==cardList.get(5)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)&&cardList.get(11)+1==cardList.get(12)&&cardList.get(12)==cardList.get(14)&&cardList.get(14)+1==cardList.get(15)&&cardList.get(15)==cardList.get(17)&&cardList.get(18)==cardList.get(19)){
                    return "FX4Y"+cardList.get(6);
                }
                //飞机在后
                if (cardList.get(19)<=11&&cardList.get(0)==cardList.get(1)&&cardList.get(2)==cardList.get(3)&&cardList.get(4)==cardList.get(5)&&cardList.get(6)==cardList.get(7)&&cardList.get(8)==cardList.get(10)&&cardList.get(10)+1==cardList.get(11)&&cardList.get(11)==cardList.get(13)&&cardList.get(13)+1==cardList.get(14)&&cardList.get(14)==cardList.get(16)&&cardList.get(16)+1==cardList.get(17)&&cardList.get(17)==cardList.get(19)){
                    return "FX4Y"+cardList.get(8);
                }
                //五飞机带五单(单不能有炸弹)
//                //飞机在前
//                if (cardList.get(0)==cardList.get(2)&&cardList.get(2)+1==cardList.get(3)&&cardList.get(3)==cardList.get(5)&&cardList.get(5)+1==cardList.get(6)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)&&cardList.get(11)+1==cardList.get(12)&&cardList.get(12)==cardList.get(14)&&cardList.get(15)!=cardList.get(18)&&cardList.get(16)!=cardList.get(19)){
//                    return "EX5Y"+cardList.get(0);
//                }
//                //飞机在中1
//                if (cardList.get(1)==cardList.get(3)&&cardList.get(3)+1==cardList.get(4)&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)&&cardList.get(9)+1==cardList.get(10)&&cardList.get(10)==cardList.get(12)&&cardList.get(12)+1==cardList.get(13)&&cardList.get(13)==cardList.get(15)&&cardList.get(16)!=cardList.get(19)){
//                    return "EX5Y"+cardList.get(1);
//                }
//                //飞机在中2
//                if (cardList.get(16)<=11&&cardList.get(2)==cardList.get(4)&&cardList.get(4)+1==cardList.get(5)&&cardList.get(5)==cardList.get(7)&&cardList.get(7)+1==cardList.get(8)&&cardList.get(8)==cardList.get(10)&&cardList.get(10)+1==cardList.get(11)&&cardList.get(11)==cardList.get(13)&&cardList.get(13)+1==cardList.get(14)&&cardList.get(14)==cardList.get(16)){
//                    return "EX5Y"+cardList.get(2);
//                }
//                //飞机在中3
//                if (cardList.get(17)<=11&&cardList.get(3)==cardList.get(5)&&cardList.get(5)+1==cardList.get(6)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)&&cardList.get(11)+1==cardList.get(12)&&cardList.get(12)==cardList.get(14)&&cardList.get(14)+1==cardList.get(15)&&cardList.get(15)==cardList.get(17)){
//                    return "EX5Y"+cardList.get(3);
//                }
//                //飞机在中4
//                if (cardList.get(18)<=11&&cardList.get(0)!=cardList.get(3)&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)&&cardList.get(9)+1==cardList.get(10)&&cardList.get(10)==cardList.get(12)&&cardList.get(12)+1==cardList.get(13)&&cardList.get(13)==cardList.get(15)&&cardList.get(15)+1==cardList.get(16)&&cardList.get(16)==cardList.get(18)){
//                    return "EX5Y"+cardList.get(4);
//                }
//                //飞机在后
//                if (cardList.get(19)<=11&&cardList.get(0)!=cardList.get(3)&&cardList.get(1)!=cardList.get(4)&&cardList.get(5)==cardList.get(7)&&cardList.get(7)+1==cardList.get(8)&&cardList.get(8)==cardList.get(10)&&cardList.get(10)+1==cardList.get(11)&&cardList.get(11)==cardList.get(13)&&cardList.get(13)+1==cardList.get(14)&&cardList.get(14)==cardList.get(16)&&cardList.get(16)+1==cardList.get(17)&&cardList.get(17)==cardList.get(19)){
//                    return "EX5Y"+cardList.get(5);
//                }
                //五飞机带五单(单可以有炸弹)
                //飞机在前
                if (cardList.get(0)==cardList.get(2)&&cardList.get(2)+1==cardList.get(3)&&cardList.get(3)==cardList.get(5)&&cardList.get(5)+1==cardList.get(6)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)&&cardList.get(11)+1==cardList.get(12)&&cardList.get(12)==cardList.get(14)){
                    return "EX5Y"+cardList.get(0);
                }
                //飞机在中1
                if (cardList.get(1)==cardList.get(3)&&cardList.get(3)+1==cardList.get(4)&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)&&cardList.get(9)+1==cardList.get(10)&&cardList.get(10)==cardList.get(12)&&cardList.get(12)+1==cardList.get(13)&&cardList.get(13)==cardList.get(15)){
                    return "EX5Y"+cardList.get(1);
                }
                //飞机在中2
                if (cardList.get(16)<=11&&cardList.get(2)==cardList.get(4)&&cardList.get(4)+1==cardList.get(5)&&cardList.get(5)==cardList.get(7)&&cardList.get(7)+1==cardList.get(8)&&cardList.get(8)==cardList.get(10)&&cardList.get(10)+1==cardList.get(11)&&cardList.get(11)==cardList.get(13)&&cardList.get(13)+1==cardList.get(14)&&cardList.get(14)==cardList.get(16)){
                    return "EX5Y"+cardList.get(2);
                }
                //飞机在中3
                if (cardList.get(17)<=11&&cardList.get(3)==cardList.get(5)&&cardList.get(5)+1==cardList.get(6)&&cardList.get(6)==cardList.get(8)&&cardList.get(8)+1==cardList.get(9)&&cardList.get(9)==cardList.get(11)&&cardList.get(11)+1==cardList.get(12)&&cardList.get(12)==cardList.get(14)&&cardList.get(14)+1==cardList.get(15)&&cardList.get(15)==cardList.get(17)){
                    return "EX5Y"+cardList.get(3);
                }
                //飞机在中4
                if (cardList.get(18)<=11&&cardList.get(4)==cardList.get(6)&&cardList.get(6)+1==cardList.get(7)&&cardList.get(7)==cardList.get(9)&&cardList.get(9)+1==cardList.get(10)&&cardList.get(10)==cardList.get(12)&&cardList.get(12)+1==cardList.get(13)&&cardList.get(13)==cardList.get(15)&&cardList.get(15)+1==cardList.get(16)&&cardList.get(16)==cardList.get(18)){
                    return "EX5Y"+cardList.get(4);
                }
                //飞机在后
                if (cardList.get(19)<=11&&cardList.get(5)==cardList.get(7)&&cardList.get(7)+1==cardList.get(8)&&cardList.get(8)==cardList.get(10)&&cardList.get(10)+1==cardList.get(11)&&cardList.get(11)==cardList.get(13)&&cardList.get(13)+1==cardList.get(14)&&cardList.get(14)==cardList.get(16)&&cardList.get(16)+1==cardList.get(17)&&cardList.get(17)==cardList.get(19)){
                    return "EX5Y"+cardList.get(5);
                }
                //最大到11(A)
                if (cardList.get(19)>11){
                    return "X";
                }
                //十连对
                if (isDoubleStraight(cardList)){
                    return "CX10Y"+cardList.get(0);
                }
            default:
                return "X";
        }
    }
}
